﻿using Arthas.Utility.Element;
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;

namespace Arthas.Controls.Metro
{
    public class MetroTabItem : TabItem
    {
        public static readonly DependencyProperty IconProperty = ElementBase.Property<MetroTabItem, ImageSource>(nameof(IconProperty), null);
        public static readonly DependencyProperty ButtonVisiblityProperty = ElementBase.Property<MetroTabItem, Visibility>(nameof(ButtonVisiblityProperty), Visibility.Visible);

        public ImageSource Icon { get { return (ImageSource)GetValue(IconProperty); } set { SetValue(IconProperty, value); } }
        public Visibility ButtonVisiblity { get { return (Visibility)GetValue(ButtonVisiblityProperty); } set { SetValue(ButtonVisiblityProperty, value); } }

        public static RoutedUICommand ButtonClickCommand = ElementBase.Command<MetroTabItem>(nameof(ButtonClickCommand));
        public event EventHandler ButtonClick;

        public MetroTabItem()
        {
            
            CommandBindings.Add(new CommandBinding(ButtonClickCommand, delegate { ButtonClick?.Invoke(this, null); }));
            Utility.Refresh(this);
        }

        static MetroTabItem()
        {
            ElementBase.DefaultStyle<MetroTabItem>(DefaultStyleKeyProperty);
        }
    }
}